import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:provider/provider.dart';

import '../controller/MS-global-user-controller.dart';
class MinePage extends StatefulWidget{
  const MinePage({super.key});

  @override
  State<StatefulWidget> createState() {
    return _MinePageState();
  }

}

class _MinePageState extends State<MinePage>{
  @override
  Widget build(BuildContext context) {
    return Consumer<MSGlobalUserController>(builder: (BuildContext context,MSGlobalUserController controller,Widget? child){
      return Scaffold(
      body: SizedBox.expand(child:DecoratedBox(
        decoration: const BoxDecoration(
            image: DecorationImage(
                image: AssetImage("images/mine-bg.png")
            )
        ),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            Padding(padding: EdgeInsets.only(top: 66.w),child: Text(controller.user!.nickname ?? "",style: TextStyle(fontSize: 35.sp,fontWeight: FontWeight.bold,color: Colors.white),),),
            Padding(padding: EdgeInsets.only(top: 10.w),child: Text("ID：${controller.user!.userId}",style: TextStyle(fontSize: 14.sp,fontWeight: FontWeight.w600,color: Color(0xCCFFFFFF)),),),
            Padding(padding: EdgeInsets.only(top: 31.w),child: Container(width: 113.w,height: 113.w,
              decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(56.5.w)
              ),
              clipBehavior: Clip.antiAlias,
              child: controller.checkAvatarIsUpdated() ? Image.network(controller.user!.avatarMiddleThumbUrl ?? "",width: 113.w,height: 113.w,fit: BoxFit.cover,):Image.asset("images/avatar-placeholder.png",width: 113.w,height: 113.w,fit: BoxFit.cover,),
            ),),
            Padding(padding: EdgeInsets.only(top: 40.w),child: InkWell(
              onTap: (){
                Navigator.of(context).pushNamed("/store");
              },
              child: DecoratedBox(
                decoration: const BoxDecoration(
                    image: DecorationImage(
                        image: AssetImage("images/mine-coin-bg.png")
                    )
                ),
                child: SizedBox(
                  width: 327.w,
                  height: 113.w,
                  child: Stack(
                    children: [
                      Positioned(top: 24.w,left: 20.w,child: Transform.rotate(
                        angle: 6,
                        child: Text("My Coins",style: TextStyle(fontSize: 14.sp,color: Color(0xFF333333),fontWeight: FontWeight.w600),),
                      ),),
                      Positioned(top: 49.w,left: 20.w,child: Transform.rotate(
                        angle: 6,
                        child: Text("${controller.user?.availableCoins ?? 0}" ,style: TextStyle(fontSize: 24.sp,color: Color(0xFF333333),fontWeight: FontWeight.bold),),
                      ),)
                    ],
                  ),
                ),
              ),
            ),),
            Padding(padding: EdgeInsets.only(top: 30.w,left: 24.w,right: 24.w),child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                InkWell(
                  onTap: (){
                    Navigator.of(context).pushNamed("/edit");
                  },
                  child: Container(
                    width: 100.w,
                    height: 100.w,
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(20.w),
                        border:Border.all(color: const Color(0xFF148857),width: 1.w)
                    ),
                    alignment: Alignment.center,
                    child: Image.asset("images/mine-edit.png",width: 50.w,fit: BoxFit.fitWidth,),
                  ),),
                InkWell(
                  onTap: (){
                    Navigator.of(context).pushNamed("/about");
                  },
                  child: Container(
                    width: 100.w,
                    height: 100.w,
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(20.w),
                        border:Border.all(color: Color(0xFF9A6E06),width: 1.w)
                    ),
                    alignment: Alignment.center,
                    child: Image.asset("images/mine-about.png",width: 50.w,fit: BoxFit.fitWidth,),
                  ),),
                InkWell(
                  onTap: (){
                    Navigator.of(context).pushNamed("/setting");
                  },
                  child: Container(
                    width: 100.w,
                    height: 100.w,
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(20.w),
                        border:Border.all(color: Color(0xFF00607E),width: 1.w)
                    ),
                    alignment: Alignment.center,
                    child: Image.asset("images/mine-setting.png",width: 50.w,fit: BoxFit.fitWidth,),
                  ),)
              ],),)
          ],
        ),
      )),
    );});
  }

}